1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.google.common.collect.testing.google;
18
19 import static com.google.common.collect.testing.features.MapFeature.SUPPORTS_REMOVE;
20
21 import com.google.common.annotations.GwtCompatible;
22 import com.google.common.collect.BiMap;
23 import com.google.common.collect.testing.features.MapFeature;
24
25
26
27
28
29
30 @GwtCompatible
31 public class BiMapClearTester<K, V> extends AbstractBiMapTester<K, V> {
32 @MapFeature.Require(SUPPORTS_REMOVE)
33 public void testClearClearsInverse() {
34 BiMap<V, K> inv = getMap().inverse();
35 getMap().clear();
36 assertTrue(getMap().isEmpty());
37 assertTrue(inv.isEmpty());
38 }
39
40 @MapFeature.Require(SUPPORTS_REMOVE)
41 public void testKeySetClearClearsInverse() {
42 BiMap<V, K> inv = getMap().inverse();
43 getMap().keySet().clear();
44 assertTrue(getMap().isEmpty());
45 assertTrue(inv.isEmpty());
46 }
47
48 @MapFeature.Require(SUPPORTS_REMOVE)
49 public void testValuesClearClearsInverse() {
50 BiMap<V, K> inv = getMap().inverse();
51 getMap().values().clear();
52 assertTrue(getMap().isEmpty());
53 assertTrue(inv.isEmpty());
54 }
55
56 @MapFeature.Require(SUPPORTS_REMOVE)
57 public void testClearInverseClears() {
58 BiMap<V, K> inv = getMap().inverse();
59 inv.clear();
60 assertTrue(getMap().isEmpty());
61 assertTrue(inv.isEmpty());
62 }
63
64 @MapFeature.Require(SUPPORTS_REMOVE)
65 public void testClearInverseKeySetClears() {
66 BiMap<V, K> inv = getMap().inverse();
67 inv.keySet().clear();
68 assertTrue(getMap().isEmpty());
69 assertTrue(inv.isEmpty());
70 }
71
72 @MapFeature.Require(SUPPORTS_REMOVE)
73 public void testClearInverseValuesClears() {
74 BiMap<V, K> inv = getMap().inverse();
75 inv.values().clear();
76 assertTrue(getMap().isEmpty());
77 assertTrue(inv.isEmpty());
78 }
79 }